package cn.iocoder.yudao.module.crm.dal.mysql.coursepackage;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.crm.controller.admin.course.vo.CoursePackagePageReqVO;
import cn.iocoder.yudao.module.crm.dal.dataobject.coursepackage.CoursePackageDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 课程套餐 Mapper
 *
 * @author 管理员
 */
@Mapper
public interface CoursePackageMapper extends BaseMapperX<CoursePackageDO> {

    default PageResult<CoursePackageDO> selectPage(CoursePackagePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<CoursePackageDO>()
                .likeIfPresent(CoursePackageDO::getName, reqVO.getName())
                .eqIfPresent(CoursePackageDO::getIcon, reqVO.getIcon())
                .eqIfPresent(CoursePackageDO::getContent, reqVO.getContent())
                .eqIfPresent(CoursePackageDO::getType, reqVO.getType())
                .eqIfPresent(CoursePackageDO::getOriginalPrice, reqVO.getOriginalPrice())
                .eqIfPresent(CoursePackageDO::getSalePrice, reqVO.getSalePrice())
                .eqIfPresent(CoursePackageDO::getCostPrice, reqVO.getCostPrice())
                .eqIfPresent(CoursePackageDO::getProtocolId, reqVO.getProtocolId())
                .eqIfPresent(CoursePackageDO::getSort, reqVO.getSort())
                .eqIfPresent(CoursePackageDO::getCoursePackageStatus, reqVO.getCoursePackageStatus())
                .eqIfPresent(CoursePackageDO::getExpirationType, reqVO.getExpirationType())
                .betweenIfPresent(CoursePackageDO::getBeginDate, reqVO.getBeginDate())
                .betweenIfPresent(CoursePackageDO::getEndDate, reqVO.getEndDate())
                .eqIfPresent(CoursePackageDO::getHomeShowStatus, reqVO.getHomeShowStatus())
                .eqIfPresent(CoursePackageDO::getStatus, reqVO.getStatus())
                .eqIfPresent(CoursePackageDO::getRemark, reqVO.getRemark())
                .betweenIfPresent(CoursePackageDO::getCreateTime, reqVO.getCreateTime())
                .in(reqVO.getSubjectIds()!=null&&!reqVO.getSubjectIds().isEmpty(),CoursePackageDO::getSubjectId,reqVO.getSubjectIds())
                .orderByDesc(CoursePackageDO::getId));
    }

}